
string file = getenv("TMP1");
string DET = "dcTa";

void a(vector<TH1F *> &v, TObject *h){
  v.push_back((TH1F *)h);
} // end if

void d2(){
  TFile *f = new TFile(file.c_str(), "UPDATE");
  TTree *etf = (TTree *)f->Get("etf");
  vector<TH1F *> v;

  // --------- 11. D2 Distribution (chi withou drift distance) ------------- - //
  etf->Draw("preTaTrackerX->GetD2()>>h1(100, 0., 20.)"); a(v,f->Get("h1"));
  etf->Draw("preTaTrackerY->GetD2()>>h2(100, 0., 20.)"); a(v,f->Get("h2"));
  etf->Draw("postTaTrackerX->GetD2()>>h3(100, 0., 50.)"); a(v,f->Get("h3"));
  etf->Draw("postTaTrackerY->GetD2()>>h4(100, 0., 50.)"); a(v,f->Get("h4"));
  // 4 dcTas tracking as a whole //
  // etf->Draw("ta4TrackerX->GetD2()>>h5(100, -0.5, 100.)"); a(v,f->Get("h5"));
  // v[4]->SetTitle("ta4TrackerX->GetD2(): 4 dcTa-s tracking as a whole");
  // etf->Draw("ta4TrackerY->GetD2()>>h6(100, -0.5, 100.)"); a(v,f->Get("h6"));
  // v[5]->SetTitle("ta4TrackerY->GetD2(): 4 dcTa-s tracking as a whole");

  TCanvas *c1 = new TCanvas("c", "D2 Distribution (chi withou drift distance)", 1680, 1050);
  c1->Divide(2,2);
  for(int i = 0; i < 4; i++){
    c1->cd(i+1); v[i]->Draw();
  } // end for
  c1->Print("d2.pdf");
} // end vis
